home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / NET / PKT_CLS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  2KB  |  91 lines

  1. #ifndef __NET_PKT_CLS_H
  2. #define __NET_PKT_CLS_H
  3.  
  4.  
  5. #include <linux/pkt_cls.h>
  6.  
  7. struct rtattr;
  8. struct tcmsg;
  9.  
  10. /* Basic packet classifier frontend definitions. */
  11.  
  12. struct tcf_result
  13. {
  14.     unsigned long    class;
  15.     u32        classid;
  16. };
  17.  
  18. struct tcf_proto
  19. {
  20.     /* Fast access part */
  21.     struct tcf_proto    *next;
  22.     void            *root;
  23.     int            (*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
  24.     u32            protocol;
  25.  
  26.     /* All the rest */
  27.     u32            prio;
  28.     u32            classid;
  29.     struct Qdisc        *q;
  30.     void            *data;
  31.     struct tcf_proto_ops    *ops;
  32. };
  33.  
  34. struct tcf_walker
  35. {
  36.     int    stop;
  37.     int    skip;
  38.     int    count;
  39.     int    (*fn)(struct tcf_proto *, unsigned long node, struct tcf_walker *);
  40. };
  41.  
  42. struct tcf_proto_ops
  43. {
  44.     struct tcf_proto_ops    *next;
  45.     char            kind[IFNAMSIZ];
  46.  
  47.     int            (*classify)(struct sk_buff*, struct tcf_proto*, struct tcf_result *);
  48.     int            (*init)(struct tcf_proto*);
  49.     void            (*destroy)(struct tcf_proto*);
  50.  
  51.     unsigned long        (*get)(struct tcf_proto*, u32 handle);
  52.     void            (*put)(struct tcf_proto*, unsigned long);
  53.     int            (*change)(struct tcf_proto*, unsigned long, u32 handle, struct rtattr **, unsigned long *);
  54.     int            (*delete)(struct tcf_proto*, unsigned long);
  55.     void            (*walk)(struct tcf_proto*, struct tcf_walker *arg);
  56.  
  57.     /* rtnetlink specific */
  58.     int            (*dump)(struct tcf_proto*, unsigned long, struct sk_buff *skb, struct tcmsg*);
  59. };
  60.  
  61. /* Main classifier routine: scans classifier chain attached
  62.    to this qdisc, (optionally) tests for protocol and asks
  63.    specific classifiers.
  64.  */
  65.  
  66. extern __inline__ int tc_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_result *res)
  67. {
  68.     int err = 0;
  69.     u32 protocol = skb->protocol;
  70.  
  71.     for ( ; tp; tp = tp->next) {
  72.         if ((tp->protocol == protocol ||
  73.              tp->protocol == __constant_htons(ETH_P_ALL)) &&
  74.             (err = tp->classify(skb, tp, res)) >= 0)
  75.             return err;
  76.     }
  77.     return -1;
  78. }
  79.  
  80. extern __inline__ unsigned long cls_set_class(unsigned long *clp, unsigned long cl)
  81. {
  82.     cl = xchg(clp, cl);
  83.     synchronize_bh();
  84.     return cl;
  85. }
  86.  
  87. extern int register_tcf_proto_ops(struct tcf_proto_ops *ops);
  88. extern int unregister_tcf_proto_ops(struct tcf_proto_ops *ops);
  89.  
  90. #endif
  91.